Repository navigation
Use eigh for PCA - #5563
Merged
Merged
Use eigh for PCA#5563
Conversation
5 of 6 tasks
Documentation build overview
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5563 +/- ##
===========================================
- Coverage 93.93% 93.93% -0.01%
===========================================
Files 184 184
Lines 22680 22679 -1
Branches 3228 3228
===========================================
- Hits 21304 21303 -1
Misses 916 916
Partials 460 460 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
orbeckst
approved these changes
Nov 27, 2026
| def _conclude(self): | ||
| self.cov /= self.n_frames - 1 | ||
| e_vals, e_vects = np.linalg.eig(self.cov) | ||
| sort_idx = np.argsort(e_vals)[::-1] |
Member
There was a problem hiding this comment.
This is ok, I just checked that eigh() since at least 1.26 returns evals in sorted order (unlike eig)
This was referenced Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Partially addresses #5351
Split out of an earlier PR, per #5352 (comment)
Changes made in this Pull Request:
eigtoeighforPCA, since the covariance matrix is symmetric by construction.This fixes the behavior flagged in #5351 (comment) where sometimes results would be complex.
eighalso uses less memory and is much faster.Rough before/after table (llm generated, it is much better at formatting these than I am) from running this benchmarking script on my macbook (script was also llm generated):
bench_pca_before_after.py
LLM / AI generated code disclosure
AI_POLICY.md.LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: not for writing the code in this diff. yes for reviewing the diff, and writing one-off benchmarking scripts like the one above.
PR Checklist
package/CHANGELOGfile updated?package/AUTHORS? (If it is not, add it!)Developers Certificate of Origin
I certify that I can submit this code contribution as described in the Developer Certificate of Origin, under the MDAnalysis LICENSE.